package tech.waterism.enums;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum FieldEnum {
    // 水库单元（STTP=RR）：坝上水位、水库入流、水库出流
    // 河道单元（STTP=ZZ、ZQ）：水位、流量
    // 缺省按：水位、流量
    RZ("坝上水位", "rz", "rsvr"),
    QIN("水库入流", "qIn", "rsvr"),
    QOUT("水库出流", "qOut", "rsvr"),
    V("水库蓄量", "v", "rsvr"),
    ZSIM("水位", "zSim", "river"),
    QSIM("流量", "qSim", "river"),
    GATE("闸门开度", "gateOpen", "gate"),
    GATE_WIDTH("闸门宽度", "gateWidth", "gate"),
    QOUT_DIFF("出流变幅", "qoutDiff", "qoutDiff"),
    Z_END("末水位", "zEnd", "zEnd"),
    // 国电
    POWER_E("发电量", "ePower", "power"),
    POWER_Q("发电流量", "qPower", "power"),
    POWER_N("出力", "nPower", "power"),
    // condition
    RAIN("降雨", "rain", "rain"),
    RUNOFF("净雨", "runoffSim", "rain"),
    RCINT("洪水频率", "rcint", "stat"),
    QPEAK("洪峰流量", "qpeak", "stat"),
    QIN_MAX("最大入流", "qinMax", "stat"),
    RZ_PEAK("调洪最高水位", "rzPeak", "stat"),
    // control
    SPILLWAY("设备", "spillway", "extra"),
    QDSC("排洪流量", "qDsc", "qDsc"),
    QDVR("分洪流量", "qDvr", "qDvr"),
    // control condition
    CTL_COND("控泄条件", "ctl_cond", "extra");

    private final String name;
    private final String field;
    private final String type;

    FieldEnum(String name, String field, String type) {
        this.name = name;
        this.field = field;
        this.type = type;
    }

    public static List<FieldEnum> getByType(String type) {
        return Stream.of(FieldEnum.values()).filter(fieldEnum -> fieldEnum.type.equals(type))
                .collect(Collectors.toList());
    }

    public String getName() {
        return name;
    }

    public String getField() {
        return field;
    }

    public String getType() {
        return type;
    }
}
